home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trading on the Edge
/
Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin
/
pc
/
mac_file
/
vendor_d
/
neuralwa
/
nw2v50
/
uio_tran.c
< prev
next >
Wrap
Text File
|
1993-08-23
|
7KB
|
218 lines
/* uio_tran.c */
/************************************************************************
* Copyright(C) 1987-1992 NeuralWare Inc *
* Penn Center West, IV-227, Pittsburgh, PA 15276 *
* Telephone: (412) 787-8222 FAX: (412) 787-8220 *
* *
* All rights reserved. No part of this program may be reproduced, *
* stored in a retrieval system, or transmitted, in any form or by any *
* means, electronic, mechanical, photocopying, recording or otherwise *
* without the prior written permission of the copyright owner, *
* NeuralWare, Inc. *
* *
* PROPRIETARY NOTICE *
* *
* This document is the property of NeuralWare, Inc. and contains *
* trade-secrets and other proprietary information. The information *
* herein is reserved as proprietary to NeuralWare, and is not to be *
* published, reproduced, copied, disclosed, used, or reverse *
* engineered without the express written consent of a duly authorized *
* representative of NeuralWare. *
************************************************************************
*/
/*********************************************************************/
/* */
/* uio_tran.c - Transfer buffer utilities for both host and UIO */
/* */
/* Author: John C. Fairman August 31, 1990 */
/* Copyright 1990 by Neuralware Inc. */
/* */
/* $Author : $ */
/* $Date : $ */
/* $Source : $ */
/* $Revision : $ */
/* $Log : $ */
/* */
/*********************************************************************/
#include "host.h"
#if defined(SUN)
#include <sys/types.h>
#endif
#ifdef MAC
#include <StdDef.h>
#endif
#if defined(IBP) || defined(I860)
#include <stddef.h>
#endif
#ifdef __TURBOC__
#include <mem.h>
#endif
#define SKIP_COMPAT_DATA 1
/* #include "userutl.h" */
#include "uio_strc.h"
#include "uio_tran.h"
#include "uio_tran.pro"
#ifdef THINK_C
#include "macuio.redef"
#endif
#if defined(VMS)
#include processes
#include stdio
#include descrip
#include iodef
#endif
/* FUNCTION */
EXPORT UNINT get_data_size(count, data_type)
NINT count;
NINT data_type;
{
UNINT size;
size = ((data_type & 0x00F0) >> 4);
size *= count;
return(size);
}
/* FUNCTION */
EXPORT VOID Put_data_into_transfer_buffer(buffer, count, data_type)
BUFFER_CHAR *buffer;
NINT count;
NINT data_type;
{
UNINT size;
size = get_data_size(count, data_type);
Data_transfer_ptr->data_descriptor.num_elements = (BUFFER_INT)count;
Data_transfer_ptr->data_descriptor.data_type = (BUFFER_INT)data_type;
if (size > SIZE_OF_UIO_BUFFER)
UIO_error_value = (NINT)OUTPUT_OVERFLOW;
else
if (buffer != (BUFFER_CHAR *)(Data_transfer_ptr->data_area.data))
MOVEMEM(Data_transfer_ptr->data_area.data, buffer, size);
}
/**/
/* FUNCTION */
EXPORT VOID Get_data_from_transfer_buffer(buffer, count, data_type)
BUFFER_CHAR *buffer;
NINT count;
NINT data_type;
{
UNINT size;
if (Data_transfer_ptr->data_descriptor.num_elements ==
(BUFFER_INT)count)
{
if (Data_transfer_ptr->data_descriptor.data_type ==
(BUFFER_INT)data_type)
{
size = get_data_size(count, data_type);
if (size > SIZE_OF_UIO_BUFFER)
UIO_error_value = (NINT)INPUT_OVERFLOW;
else
{
if (buffer !=
(BUFFER_CHAR *)(Data_transfer_ptr->data_area.data))
{
MOVEMEM(buffer, Data_transfer_ptr->data_area.data, size);
}
}
return;
}
}
UIO_error_value = (NINT)INPUT_CORRUPTION;
}
/**/
#if defined(VMS)
/*
VMS Mailbox read/write routines (rewrapper)
writing is to the channel (integer; -1 on fail) created by 'newmailbox'.
The routines getmailboxbytes/putmailboxbytes return the codes 0-error,
else number of bytes read (written). The lengths are not used by NW2,
as the buf sizes are implicit in the buffer contents.
*/
/* VMS structure for mailboxes */
typedef struct
{
short cond_value;
short count;
int info;
} io_statblk;
io_statblk iosb;
short newmailbox(boxname)
char *boxname;
{
int stat;
short vmschan;
$DESCRIPTOR(mailbox, "hi"); /* dummy VMS system call descriptor */
mailbox.dsc$a_pointer = boxname; /* add string (ptr) */
mailbox.dsc$w_length = strlen(boxname); /* and # of chars (not null) */
/* see also: VMS Programmer's Volume 4B: System Services; pg SYS-82 */
stat = SYS$CREMBX( 0, /* zero for TEMPORARY (sub) process */
&vmschan, /* mandatory assigned channel */
8192, /* maxmsg */
8192, /* bufquo */
0, /* promsk */
0, /* acmode */
&mailbox); /* logname */
if ((stat & 1) != 1)
{
LIB$SIGNAL(stat); /* error */
return(-1);
}
return(vmschan);
}
getmailboxbytes(ch, bufaddr, len)
char *bufaddr;
int len;
short ch;
{
io_statblk iosb;
int stat;
stat = SYS$QIOW(2, ch, IO$_READVBLK, &iosb, 0, 0, bufaddr, len, 0,0,0,0);
if ((stat & 1) != 1) LIB$STOP(stat);
if ((iosb.cond_value & 1) != 1) LIB$STOP(iosb.cond_value);
return(iosb.count);
}
putmailboxbytes(ch, bufaddr, len)
char *bufaddr;
int len;
short ch;
{
io_statblk iosb;
int stat;
/* write message to the mailbox channel 'vmschan' */
stat = SYS$QIOW(1, ch, IO$_WRITEVBLK, &iosb, 0, 0, bufaddr, len, 0,0,0,0);
if ((stat & 1) != 1) LIB$STOP(stat);
if ((iosb.cond_value & 1) != 1) LIB$STOP(iosb.cond_value);
return(len); /* OK */
}
squeal(msg)
char *msg;
{
fprintf(stderr,"%s", msg);
fflush(stderr);
}
#endif /* (VMS) */